﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace HelloWPF.DependencyAttachedProperty
{
    /// <summary>
    /// DependenceProperty.xaml 的交互逻辑
    /// </summary>
    public partial class DependenceAattachedPropertyByPasswordWin : Window
    {
        public DependenceAattachedPropertyByPasswordWin()
        {
            InitializeComponent();
            MyPassword = "123456";
            MyName = "qqq";
            this.DataContext = this;
        }

        /// <summary>
        /// CLR属性包装器
        /// 包装器的作用是以“实例属性”的形式向外界暴露依赖属性
        /// 这样依赖属性才能成为数据源的一个Path
        /// </summary>
        private string _password;
        public string MyPassword
        {
            get { return _password; }
            set { _password = value; }
        }

        /// <summary>
        /// CLR属性包装器
        /// 包装器的作用是以“实例属性”的形式向外界暴露依赖属性
        /// 这样依赖属性才能成为数据源的一个Path
        /// </summary>
        private string _name;
        public string MyName
        {
            get { return _name; }
            set { _name = value; }
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var a = rootGrid.FindName("qqq") as TextBox;
            foreach (Control item in rootGrid.Children)
            {
                if (item.Name == "qqq")
                {
                    item.Focus();
                }
            }
        }
    }
}
